#!/bin/env ruby
# encoding: utf-8
require_relative '../spec/spec_helper'
require_relative '../spec/commons/user_auth'
require_relative '../spec/commons/check_pages'

describe 'Reset password page' do
	before {

	}

 
  context 'when open reset_page' do
  	it 'then it should be correct' do
  		goto 'http://pulse.7bits.it/en/us/reset-password'
  		(browser.text.include? 'Reset password').should be_truthy  
  		(browser.text.include? 'Pulse').should be_truthy  
  		text_field(class: "form-control", name: "username").wait_until_present
  		button(class: "btn btn-primary btn-block js-submit-btn", text: 'OK').should be_present
  	end
  end
 
  # -- submit empty input:  “Email can't be blank”
  context 'when submit empty input' do
    it 'then email cannot be blank' do
      text_field(class: "form-control", name: "username").clear
      button(class: "btn btn-primary btn-block js-submit-btn", text: 'OK').click
      span(class: "help-block", text: "Email can't be blank").should be_present
    end
  end

  # -- submit string with length more than 255:  “Email should contain no more than 255 symbols”
  context 'when submit email' do
    it 'then it should contain no more than 255 symbols' do
      ustr='a'
      254.times{|i| ustr+='a'}
      ustr=ustr+'@q.qq'
      text_field(class: "form-control", name: "username").set ustr
      button(class: "btn btn-primary btn-block js-submit-btn", text: 'OK').click
      span(class: "help-block", text: "Email should contain no more than 255 symbols").should be_present      
    end
  end
 
  # -- submit invalid email: “Can't find that email, sorry”
  context 'when submit invalid input' do
    it "then can't find that email" do
      text_field(class: "form-control", name: "username").clear
      text_field(class: "form-control", name: "username").set "@wertu."
      button(class: "btn btn-primary btn-block js-submit-btn", text: 'OK').click
      span(class: "help-block", text: "Can't find that email, sorry").should be_present
    end
  end

  # -- submit unexisted email: “Can't find that email, sorry”
  context 'when submit  unexisted input' do
    it "then can't find that email" do
      text_field(class: "form-control", name: "username").clear
      text_field(class: "form-control", name: "username").set "qwert@asdfh.rw"
      button(class: "btn btn-primary btn-block js-submit-btn", text: 'OK').click
      span(class: "help-block", text: "Can't find that email, sorry").should be_present
    end
  end


 # -- submit email, which is bound with not activated account: “Sorry, account with that email is not enabled yet.”
  #TODO create account, that is not activated yet
  



end 